package com.tencent.stat.common;

import android.content.Context;
import android.os.Environment;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;

public class d
{
  private static String a()
  {
    System.out.println("--------func start--------");
    Log.i("test", "--------func start--------");
    StringBuffer localStringBuffer = new StringBuffer();
    while (true)
    {
      String str;
      try
      {
        Object localObject = new ArrayList();
        ((ArrayList)localObject).add("logcat");
        ((ArrayList)localObject).add("-d");
        ((ArrayList)localObject).add("-v");
        ((ArrayList)localObject).add("time");
        ArrayList localArrayList = new ArrayList();
        localArrayList.add("logcat");
        localArrayList.add("-c");
        localObject = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec((String[])((ArrayList)localObject).toArray(new String[((ArrayList)localObject).size()])).getInputStream()));
        str = ((BufferedReader)localObject).readLine();
        if (str == null)
          break label179;
        Runtime.getRuntime().exec((String[])localArrayList.toArray(new String[localArrayList.size()]));
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        System.out.println("--------func end--------");
        Log.i("test", "--------func end--------");
        return localStringBuffer.toString();
      }
      label179: if (str != null)
        continue;
      System.out.println("--   is null   --");
      Log.i("test", "--------is null--------");
    }
  }

  public static void a(Context paramContext)
  {
    Object localObject5 = null;
    Object localObject6 = null;
    Object localObject4 = null;
    Object localObject2 = localObject4;
    Object localObject3 = localObject5;
    Object localObject1 = localObject6;
    try
    {
      String str = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString();
      localObject2 = localObject4;
      localObject3 = localObject5;
      localObject1 = localObject6;
      new StringBuilder().append(str).append("/HealthRecord/test.log");
      localObject2 = localObject4;
      localObject3 = localObject5;
      localObject1 = localObject6;
      str = a();
      localObject2 = localObject4;
      localObject3 = localObject5;
      localObject1 = localObject6;
      paramContext = paramContext.getApplicationContext().openFileOutput("feedback.log", 1);
      if (paramContext != null)
      {
        localObject2 = paramContext;
        localObject3 = paramContext;
        localObject1 = paramContext;
        paramContext.write(str.getBytes());
        localObject2 = paramContext;
        localObject3 = paramContext;
        localObject1 = paramContext;
      }
      try
      {
        paramContext.close();
        return;
      }
      catch (IOException paramContext)
      {
        paramContext.printStackTrace();
        return;
      }
    }
    catch (java.io.FileNotFoundException paramContext)
    {
      localObject1 = localObject2;
      try
      {
        ((FileOutputStream)localObject2).close();
        return;
      }
      catch (IOException paramContext)
      {
        paramContext.printStackTrace();
        return;
      }
    }
    catch (IOException paramContext)
    {
      localObject1 = localObject3;
      try
      {
        ((FileOutputStream)localObject3).close();
        return;
      }
      catch (IOException paramContext)
      {
        paramContext.printStackTrace();
        return;
      }
    }
    finally
    {
      if (localObject1 != null);
      try
      {
        ((FileOutputStream)localObject1).close();
        throw paramContext;
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
      }
    }
  }
}